package com.lap.web.starter.ip;

import com.lap.web.starter.ip.valueobject.ClientInfo;
import com.lap.web.starter.ip.valueobject.UserAgentInfo;
import jakarta.servlet.http.HttpServletRequest;
import lombok.experimental.UtilityClass;

@UtilityClass
public class ClientInfoResolver {

  public static ClientInfo resolve(HttpServletRequest request) {
    String uaString = request.getHeader("User-Agent");
    UserAgentInfo ua = UserAgentParser.parse(uaString);
    String ip = IpUtils.getClientIp(request);
    return new ClientInfo(ip, ua);
  }
}
